package model;

/**
 * Publicly accessible struct representing a single card
 */
public class Card {
	/** Numerical value of the card: A=1, K=13, Q=12, J=11, 10, 9, ..., small joker=14, big joker=15 */
	public int value; 
	/** Suit value of the card*/
	public Suit suit; 
	/** Unique ID of the card*/
	public int id;
	/** A rolling counter to ensure uniqueness of IDs */
	private static int idCounter = 55555;
	public Card(int value, Suit suit) {
		this.id = idCounter;
		idCounter++;
		this.value=value;
		this.suit=suit;
		if(value<0||value>15||value>13&&suit!=Suit.JOKER)
			throw new RuntimeException("Attempting to construct an invalid card value!");
		if(idCounter==Integer.MAX_VALUE)
			throw new RuntimeException("Ran out of initialization space for cards. Cannot create any more cards!");
	}
	public boolean isSmallJoker() {
		return value==14;
	}
	public boolean isBigJoker() {
		return value==15;
	}
	public boolean isJoker() {
		return isSmallJoker()||isBigJoker();
	}
	public String toString() {
		return this.value+"-"+this.suit;
	}
	
	public String toMessage() 
	{
		return this.value + "-" + this.suit;
		
	}
}
